/**
 * @FileDescription 生产存储api
 * @Author 祝小文
 * @CreateDate 2022-10-11 11:27
 */
import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

//查询菜单统计信息
export const queryMenuTjInfo = (params: any) =>
  request.get(`/menu-tj/queryMenuTjInfo`, { params }).then((res) => adapter(res as any))

/** 罐区API Start */
//查询罐区信息
export const queryGqxxInfo = (params?: any) =>
  request.get(`/gqxx/queryGqxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 罐区信息
export const insertOrUpdateGqxx = (params?: any) =>
  request.post(`/gqxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询储罐列表
export const queryCgxxInfoList = (params?: any) =>
  request.get(`/cgxx/queryCgxxInfoList`, { params }).then((res) => adapter(res as any))

//根据储罐详细信息
export const queryCgxxInfo = (params?: any) =>
  request.get(`/cgxx/queryCgxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 储罐信息
export const insertOrUpdateCgxx = (params?: any) =>
  request.post(`/cgxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询上一条储罐信息
export const queryLastCgxxInfo = (params?: any) =>
  request.get(`/cgxx/queryLastCgxxInfo`, { params }).then((res) => adapter(res as any))
/** 罐区API End */

//新增装置区--主要危险介质信息表
export const AddinsertOrUpdate_z = (params?: any) =>
  request.post(`/zywxjzxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//修改装置区--主要危险介质信息表
export const reinsertOrUpdate_z = (params?: any) =>
  request.post(`/zywxjzxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//根据id查询4、装置区--主要危险介质信息表
export const queryZywxjzxxInfo = (params?: any) =>
  request.get(`/zywxjzxx/queryZywxjzxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 装置
export const insertOrUpdateZZXX = (params?: any) =>
  request.post(`/zzqxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询装置详细信息
export const queryZZXXInfo = (params?: any) =>
  request.get(`/zzqxx/queryZzqxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 单元
export const insertOrUpdateDYXX = (params?: any) =>
  request.post(`/dyxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询单元详细信息
export const queryDYXXInfo = (params?: any) =>
  request.get(`/dyxx/queryDyxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 设备
export const insertOrUpdateSBXX = (params?: any) =>
  request.post(`/sbxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询设备详细信息
export const querySBXXInfo = (params?: any) =>
  request.get(`/sbxx/querySbxxInfo`, { params }).then((res) => adapter(res as any))

/** 仓库API */
//新增/修改 仓库
export const insertOrUpdateCkxx = (params?: any) =>
  request.post(`/ckxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询仓库详细信息
export const queryCkxxInfo = (params?: any) =>
  request.get(`/ckxx/queryCkxxInfo`, { params }).then((res) => adapter(res as any))

/** 堆场API */
//新增/修改 堆场
export const insertOrUpdateDcxx = (params?: any) =>
  request.post(`/dcxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询堆场详细信息
export const queryDcxxInfo = (params?: any) =>
  request.get(`/dcxx/queryDcxxInfo`, { params }).then((res) => adapter(res as any))

/** 火炬API */
//新增/修改 火炬设施
export const insertOrUpdateHjssxx = (params?: any) =>
  request.post(`/hjqxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询火炬设施详细信息
export const queryHjssxxInfo = (params?: any) =>
  request.get(`/hjqxx/queryHjqxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 火炬
export const insertOrUpdateHjxx = (params?: any) =>
  request.post(`/hjxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//查询火炬详细信息
export const queryHjxxInfo = (params?: any) =>
  request.get(`/hjxx/queryHjxxInfo`, { params }).then((res) => adapter(res as any))

//根据qyid查询dcs设备信息
export const queryDcsSbInfo = (params?: any) =>
  request.get(`/dcs-sb/queryDcsSbInfo`, { params }).then((res) => adapter(res as any))

//根据id查询dcs绑定表
export const queryDcsBdInfo = (params?: any) =>
  request.get(`/dcs-bd/queryDcsBdInfo`, { params }).then((res) => adapter(res as any))

//新增或修改14、dcs绑定表
export const insertOrUpdate_dcs = (params?: any) =>
  request.post(`/dcs-bd/insertOrUpdate`, params).then((res) => adapter(res as any))
